package j2024.j202409;

import java.util.Arrays;
import java.util.Scanner;

public class j0924 {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        int ret = 100;
        for (int i = 1; i < str.length(); i++) {
            if(str.charAt(i)==str.charAt(i-1)){
                ret = 2;
                break;
            }
            int left = i-1,right = i+1;
            if(right<str.length() && str.charAt(left)==str.charAt(right)){
                ret = 3;
            }
        }
        System.out.println(ret==100?-1:ret);
    }

    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        int[] yes = new int[n];
        int[] no = new int[n];
        yes[0] = arr[0];
        for (int i = 1; i < n; i++) {
            yes[i] = no[i-1]+arr[i];
            no[i] = Math.max(no[i-1],yes[i-1]);
        }
        System.out.println(Math.max(no[n-1],yes[n-1]));
    }

    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(),p = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        Arrays.sort(arr);
        int mid = (n-1)/2;
        int left = mid-1,right = mid+1;
        int cou = 0;
        while(left>=0 && Math.abs(arr[left]-arr[mid])<=p){
            left--;
            cou++;
        }
        while(right<n && (arr[right]-arr[mid])<=p){
            right++;
            cou++;
        }
        System.out.println(cou+1);
    }
}
